package com.sls.web.manager.querybean.base;

import java.io.Serializable;

import com.sls.web.manager.common.Constants;

/**
 * 分页基类
 * 
 * @author SXF
 * 
 */
public class BaseQuery implements Serializable {

	private static final long serialVersionUID = 3165341447763021203L;

	private Integer offset;
	private Integer limit;

	private Integer pageSize;// 每页记录数
	private Integer currentPage;// 当前页数

	public BaseQuery() {
			calculate();
	}

	public BaseQuery(Integer offset, Integer limit) {
		this.offset = offset;
		this.limit = limit;
	}

	public void calculate() {
		if (pageSize != null && currentPage != null) {
			this.limit = pageSize;
			this.offset = (currentPage - 1) * pageSize;
		}else {
			pageSize=Constants.INIT_PAGESIZE;
			currentPage=Constants.INIT_CURRENTPAGE;
		}
		
	}

	public Integer getOffset() {
		return offset;
	}

	public void setOffset(Integer offset) {
		this.offset = offset;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

}
